﻿using CatUtils.Utils.Currency.IoUtils;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CatUtils.LocalUtils.Tool
{/// <summary>
///
/// </summary>
    public class GenerateTool
    {
        /// <summary>
        /// 创建编译文件
        /// </summary>
        /// <param name="richTextBox"></param>
        /// <param name="FloderPath"></param>
        public void CreateGenerate(RichTextBox richTextBox, string FloderPath)
        {
            if (FloderPath == "")
                return;
            List<string> ContentList = new List<string>() { "md \"$(SolutionDir)CatUtils\\bin\\Debug\\Bin\\Import\\\"" };
            string CreateText = "Move  \"$(SolutionDir){0}{1}\"  \"$(SolutionDir){0}Bin\\Import\\\"";

            string ParentPath = GetParentPath(FloderPath);

            foreach (var item in FloderNameHelper.GetFileNameList(FloderPath))
            {
                Console.WriteLine(item);
                if (item.IndexOf("exe.config") >= 0)
                    continue;
                ContentList.Add(string.Format(CreateText, ParentPath, item));
            }
            richTextBox.Lines = ContentList.ToArray();
        }

        /// <summary>
        /// 获取多级目录上的结果
        /// </summary>
        /// <param name="FloderPath"></param>
        /// <returns></returns>
        private string GetParentPath(string FloderPath)
        {
            string TempPath = FloderPath;
            for (int i = 0; i < 4; i++)
            {
                FloderPath = FloderNameHelper.GetParentFloderPath(FloderPath);
                Console.WriteLine(FloderPath);
            }
            TempPath = TempPath.Replace(FloderPath, "").Substring(1);
            return TempPath;
        }
    }
}